package _java8新特性._lambda;


import java.util.function.Consumer;
import java.util.function.Function;

public class Demo_05 {

    public static <T, R> R convToDouble(Function<T, R> consumer, T t) {
        R ans = consumer.apply(t);
        return ans;
    }

    public static void main(String[] args) {
        String str_1 = "123.45";
        double ans_1 = convToDouble(str -> Double.parseDouble(str), str_1);
        System.out.println(ans_1);

        Integer int_1 = 89;
        String ans_2 = convToDouble(i -> String.valueOf(i), int_1);
        System.out.println(ans_2);
    }

}
